﻿Imports SdlDotNet.Graphics
Imports SdlDotNet.Input
Imports System.Drawing

Public Class GameplayMenuContainer
    Private Position As Point
    Private WithEvents StartMenu As StartMenu
    Private WithEvents DeployWeaponMenu As DeployWeaponMenu
    Private WithEvents DeployDefenseMenu As DeployDefenseMenu
    Private WithEvents LaunchMissileMenu As LaunchMissileMenu
    Private WithEvents BombMenu As BombMenu
    Private CurrentMenu As IMenu

    Public Event ClickedBuildButton()
    Public Event ClickedPropagandaButton()
    Public Event ClickedDeployMissile(ByVal missileType As MissileAndWarheadTypes)
    Public Event ClickedLaunchMissile(ByVal warheadType As MissileAndWarheadTypes)
    Public Event ClickedBombButton(ByVal warheadType As MissileAndWarheadTypes)
    Public Event ClickedDeployAntiMissile()
    Public Event ClickedDeployAntiAircraft()
    Public Event ClickedDeployBomber()

    Public Sub Draw(ByRef display As Surface)
        CurrentMenu.Draw(display)
    End Sub

    Public Sub New(ByVal position As Point, ByVal player As Player)
        Me.Position = position
        StartMenu = New StartMenu(position, player)
        DeployWeaponMenu = New DeployWeaponMenu(position, player)
        DeployDefenseMenu = New DeployDefenseMenu(position, player)
        LaunchMissileMenu = New LaunchMissileMenu(position, player)
        BombMenu = New BombMenu(position, player)

        CurrentMenu = StartMenu
    End Sub

    Public Sub ShowMenuForPlayer(ByRef player As Player)
        StartMenu.ShowMenuForPlayer(player)
        DeployWeaponMenu.ShowMenuForPlayer(player)
        DeployDefenseMenu.ShowMenuForPlayer(player)
        LaunchMissileMenu.ShowMenuForPlayer(player)
        BombMenu.ShowMenuForPlayer(player)

        CurrentMenu = StartMenu
    End Sub

    Public Sub HandleMouseButtonUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
        CurrentMenu.HandleMouseButtonUp(sender, e)
    End Sub

    Public Sub HandleMouseMotion(ByVal sender As Object, ByVal e As MouseMotionEventArgs)
        CurrentMenu.HandleMouseMotion(sender, e)
    End Sub

    Private Sub StartMenu_ClickedBombButton() Handles StartMenu.ClickedBombButton
        CurrentMenu = BombMenu
    End Sub

    Private Sub StartMenu_ClickedAttackButton() Handles StartMenu.ClickedLaunchMissileButton
        CurrentMenu = LaunchMissileMenu
    End Sub

    Private Sub StartMenu_ClickedBuildButton() Handles StartMenu.ClickedBuildButton
        RaiseEvent ClickedBuildButton()
    End Sub

    Private Sub StartMenu_ClickedDeployDefenseButton() Handles StartMenu.ClickedDeployDefenseButton
        CurrentMenu = DeployDefenseMenu
    End Sub

    Private Sub StartMenu_ClickedDeployWeaponButton() Handles StartMenu.ClickedDeployWeaponButton
        CurrentMenu = DeployWeaponMenu
    End Sub

    Private Sub StartMenu_ClickedPropagandaButton() Handles StartMenu.ClickedPropagandaButton
        RaiseEvent ClickedPropagandaButton()
    End Sub

    Private Sub DeployWeaponMenu_ClickedBomberButton() Handles DeployWeaponMenu.ClickedBomberButton
        RaiseEvent ClickedDeployBomber()
    End Sub

    Private Sub DeployWeaponMenu_ClickedCancelButton() Handles DeployWeaponMenu.ClickedCancelButton
        CurrentMenu = StartMenu
    End Sub

    Private Sub DeployDefenseMenu_ClickedAntiAircraftButton() Handles DeployDefenseMenu.ClickedAntiAircraftButton
        RaiseEvent ClickedDeployAntiAircraft()
    End Sub

    Private Sub DeployDefenseMenu_ClickedAntiMissileButton() Handles DeployDefenseMenu.ClickedAntiMissileButton
        RaiseEvent ClickedDeployAntiMissile()
    End Sub

    Private Sub DeployDefenseMenu_ClickedCancelButton() Handles DeployDefenseMenu.ClickedCancelButton
        CurrentMenu = StartMenu
    End Sub

    Private Sub AttackMenu_ClickedCancelButton() Handles LaunchMissileMenu.ClickedCancelButton
        CurrentMenu = StartMenu
    End Sub

    Private Sub DeployWeaponMenu_ClickedMissileButton(ByVal missileType As MissileAndWarheadTypes) Handles DeployWeaponMenu.ClickedMissileButton
        RaiseEvent ClickedDeployMissile(missileType)
    End Sub

    Private Sub AttackMenu_ClickedWarheadButton(ByVal warheadType As MissileAndWarheadTypes) Handles LaunchMissileMenu.ClickedWarheadButton
        RaiseEvent ClickedLaunchMissile(warheadType)
    End Sub

    Private Sub BombMenu_ClickedCancelButton() Handles BombMenu.ClickedCancelButton
        CurrentMenu = StartMenu
    End Sub

    Private Sub BombMenu_ClickedWarheadButton(ByVal warheadType As MissileAndWarheadTypes) Handles BombMenu.ClickedWarheadButton
        RaiseEvent ClickedBombButton(warheadType)
    End Sub
End Class
